package com.shrct.businessprocess.product.impl;

import com.shrct.businessprocess.product.RCBrand;
import com.shrct.businessprocess.product.RCProductCategory;
import com.shrct.businessprocess.product.RCProductMetaType;
import com.shrct.businessprocess.product.RCProductSpecification;
import com.shrct.businessprocess.product.impl.RCBrandImpl;
import com.shrct.businessprocess.product.impl.RCProductCategoryImpl;
import com.shrct.businessprocess.product.proxy.RCProductSpecificationProxy;
import edu.fudan.mylang.pf.BaseModelObject;
import edu.fudan.mylang.pf.IObjectFactory;
import javax.persistence.CascadeType;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
import org.hibernate.annotations.DiscriminatorOptions;

@Entity
@DiscriminatorValue("RCPRODUCTSPECIFICATION_TYPE")
@DiscriminatorOptions(force = true)
@DiscriminatorColumn(length = 64)
@Table(name = "rcproductspecification")
public class RCProductSpecificationImpl extends BaseModelObject implements RCProductSpecification {
  public RCProductSpecificationImpl() {
    super();
  }
  
  private String code;
  
  public String getCode() {
    return this.code;
  }
  
  public RCProductSpecification setCode(final String code) {
    this.code = code;
    return this;			
    
  }
  
  private String normalizedCode;
  
  public String getNormalizedCode() {
    return this.normalizedCode;
  }
  
  public RCProductSpecification setNormalizedCode(final String normalizedCode) {
    this.normalizedCode = normalizedCode;
    return this;			
    
  }
  
  @JoinColumn(name = "productCategory_id")
  @ManyToOne(targetEntity = RCProductCategoryImpl.class, cascade = { CascadeType.MERGE, CascadeType.PERSIST })
  private RCProductCategory productCategory;
  
  public RCProductCategory getProductCategory() {
    return this.productCategory;
  }
  
  public RCProductSpecification setProductCategory(final RCProductCategory productCategory) {
    this.productCategory = productCategory;
    return this;			
    
  }
  
  private String name;
  
  public String getName() {
    return this.name;
  }
  
  public RCProductSpecification setName(final String name) {
    this.name = name;
    return this;			
    
  }
  
  private String details;
  
  public String getDetails() {
    return this.details;
  }
  
  public RCProductSpecification setDetails(final String details) {
    this.details = details;
    return this;			
    
  }
  
  @JoinColumn(name = "brand_id")
  @ManyToOne(targetEntity = RCBrandImpl.class, cascade = { CascadeType.MERGE, CascadeType.PERSIST })
  private RCBrand brand;
  
  public RCBrand getBrand() {
    return this.brand;
  }
  
  public RCProductSpecification setBrand(final RCBrand brand) {
    this.brand = brand;
    return this;			
    
  }
  
  private RCProductMetaType productMetaType;
  
  public RCProductMetaType getProductMetaType() {
    return this.productMetaType;
  }
  
  public RCProductSpecification setProductMetaType(final RCProductMetaType productMetaType) {
    this.productMetaType = productMetaType;
    return this;			
    
  }
  
  public String getEntityName() {
    return this.code;
  }
  
  public static RCProductSpecification create(final IObjectFactory objectFactory) {
    com.shrct.businessprocess.product.RCProductSpecification rCProductSpecification = new com.shrct.businessprocess.product.impl.RCProductSpecificationImpl(
    );
    objectFactory.create(rCProductSpecification);
    return rCProductSpecification;			
    
  }
  
  public static RCProductSpecification createRCProductSpecificationImpl(final IObjectFactory objectFactory, final Procedure1<RCProductSpecification> init) {
    com.shrct.businessprocess.product.RCProductSpecification rCProductSpecification = new com.shrct.businessprocess.product.impl.RCProductSpecificationImpl(
    );
    objectFactory.create(rCProductSpecification);
    init.apply(rCProductSpecification);
    
    return rCProductSpecification;			
    
  }
  
  public RCProductSpecificationProxy toProxy() {
    com.shrct.businessprocess.product.proxy.RCProductSpecificationProxy proxy = new com.shrct.businessprocess.product.proxy.RCProductSpecificationProxy();
    proxy.setId(this.getId());
    if(this instanceof edu.fudan.mylang.pf.INamedModelObject){
    	proxy.setName(((edu.fudan.mylang.pf.INamedModelObject)this).getEntityName());
    }
    return proxy;
    
  }
}
